﻿#include "AppDelegate.h"
#include "RootWindow.h"
#include "C2DXShareSDK/C2DXShareSDK.h"


using namespace cn::sharesdk;
USING_NS_CC;


AppDelegate::AppDelegate()
{

}



AppDelegate::~AppDelegate()
{

}

bool AppDelegate::applicationDidFinishLaunching()
{

	//初始化ShareSDK
	C2DXShareSDK::open(CCString::create("9ab12b35c307"), false);


	//初始化社交平台信息
	this->initPlatformConfig();


	// initialize director
	CAApplication* pDirector = CAApplication::getApplication();

	CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

	pDirector->setOpenGLView(pEGLView);


	/*
	C2DXShareSDK::open(CCString::create("api5"), false);
	CCDictionary *wechatMomentsConfigDict = CCDictionary::create();
	wechatMomentsConfigDict->setObject(CCString::create("wx3f8e02fd5d75f23d"), "app_id");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeWeixiTimeline, wechatMomentsConfigDict);
	C2DXShareSDK::open(CCString::create("api6"), false);
	CCDictionary *wechatMomentsConfigDict6 = CCDictionary::create();
	wechatMomentsConfigDict6->setObject(CCString::create("wx3f8e02fd5d75f23d"), "app_id");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeWeixiFav, wechatMomentsConfigDict6);
	*/
	// run
	pDirector->runWindow(RootWindow::create());

	return true;
}

// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
	CAApplication::getApplication()->stopAnimation();

	// if you use SimpleAudioEngine, it must be pause
	// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
	CAApplication::getApplication()->startAnimation();

	// if you use SimpleAudioEngine, it must resume here
	// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}


void AppDelegate::initPlatformConfig()
{
	//新浪微博
	CCDictionary *sinaConfigDict = CCDictionary::create();
	sinaConfigDict->setObject(CCString::create("1549920978"), "app_key");
	sinaConfigDict->setObject(CCString::create("e67d542780a179218d0e79fbe278a434"), "app_secret");
	sinaConfigDict->setObject(CCString::create("http://www.sharesdk.cn"), "redirect_uri");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeSinaWeibo, sinaConfigDict);

	//腾讯微博
	CCDictionary *tcConfigDict = CCDictionary::create();
	tcConfigDict->setObject(CCString::create("1104610963"), "app_key");
	tcConfigDict->setObject(CCString::create("zAO8IlxWmdJZ8Ugo"), "app_secret");
	tcConfigDict->setObject(CCString::create("http://www.sharesdk.cn"), "redirect_uri");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeTencentWeibo, tcConfigDict);

	//短信
	//C2DXShareSDK::setPlatformConfig(C2DXPlatTypeSMS, NULL);

	//QQ空间
	CCDictionary *qzConfigDict = CCDictionary::create();
	qzConfigDict->setObject(CCString::create("1104610963"), "app_id");
	qzConfigDict->setObject(CCString::create("zAO8IlxWmdJZ8Ugo"), "app_key");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeQZone, qzConfigDict);

	//微信
	CCDictionary *wcConfigDict = CCDictionary::create();
	wcConfigDict->setObject(CCString::create("wx5228351c4e9ff31e"), "app_id");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeWeixiSession, wcConfigDict);
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeWeixiTimeline, wcConfigDict);
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeWeixiFav, wcConfigDict);

	//QQ
	CCDictionary *qqConfigDict = CCDictionary::create();
	qqConfigDict->setObject(CCString::create("1104610963"), "app_id");
	C2DXShareSDK::setPlatformConfig(C2DXPlatTypeQQ, qqConfigDict);


}
